/* 重命名文件 193.c */


.LC0:
	.string "please input the file name which do you want to change:\n"

.LC1:
	.string "%s"

.LC2:
	.string "r"

.LC3:
	.string "%s open successfully"

.LC4:
	.string "\nplease input new name!"

.LC5:
	.string "cannot find!!"

.globl main

main:
	pushq %rbp
	movq %rsp,%rbp
	subq $0x1000,%rsp

	movq $0,-0x1000(%rbp) /* fp */
	movl $0,-0xff8(%rbp) /* filename1 */
	movl $0,-0xfe4(%rbp) /* filename2*/

	leaq .LC0(%rip),%rdi
	movl $0,%eax 
	call printf 

	leaq -0xff8(%rbp),%rsi /* filename1 */
	leaq .LC1(%rip),%rdi
	movl $0,%eax 
	call scanf 

	leaq .LC2(%rip),%rsi
	leaq -0xff8(%rbp),%rdi /* filename1 */
	movl $0,%eax 
	call fopen 
	movq %rax,-0x1000(%rbp) /* fp */
	cmpq $0,-0x1000(%rbp) /* fp */
	je .Lmain_400

	leaq -0xff8(%rbp),%rsi /* filename1 */
	leaq .LC3(%rip),%rdi
	movl $0,%eax 
	call printf 

	leaq .LC4(%rip),%rdi
	movl $0,%eax 
	call printf 

	leaq -0xfe4(%rbp),%rsi /* filename2 */
	leaq .LC1(%rip),%rdi
	movl $0,%eax 
	call scanf 

	leaq -0xfe4(%rbp),%rsi /* filename2 */
	leaq -0xff8(%rbp),%rdi /* filename1 */
	movl $0,%eax 
	call rename 

	movq -0x1000(%rbp),%rdi /* fp */
	movl $0,%eax 
	call fclose 

	jmp .Lmain_0

.Lmain_400:
	leaq .LC5(%rip),%rdi
	movl $0,%eax 
	call printf 

	movl $0,%edi
	movl $0,%eax 
	call exit 

.Lmain_0:
	movl $0,%eax
	leave
	ret
